#!/bin/bash
# SPDX-License-Identifier: MulanPSL-2.0+
# Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved.

# fix files permissions cause container service start failed
umask 002

download_repo()
{
	local repo="$1"
	local commit_id="$2"

	[ -d "/c/$repo/.git" ] || {
		git clone https://gitee.com/wu_fengguang/"$repo".git /c/"$repo"
		chmod -R o+r /c/"$repo"
		
		[ "$repo" == "compass-ci" ] && ln -s /c/"$repo" /c/cci
	}

	cd /c/"$repo" || exit
	[ -n "$commit_id" ] && git reset --hard "$commit_id"
}

download_repo "compass-ci" "$compass_commit_id"
download_repo "lkp-tests" "$lkp_commit_id"
download_repo "upstream-repos" "$upstream_commit_id"
